package com.qunduikj.sjb.sdk.model.enums;

/**
 * @author June @http://litesuits.com
 * @date 2015-08-20
 * 1过路费 2加油 3汽车保养 4违章费用 5食 6住 7娱乐 8其他
 */
public enum CostType {
    // 利用构造函数传参
    RoadToll(1, "过路费"), AddCheer(2, "加油"), CarUpkeep(3, "汽修保养"), ViolationMoney(4, "违章费用"), Food(5, "餐食"),
    Live(6, "住宿"), Recreation(7, "娱乐"), Else(8, "其他");

    // 定义私有变量
    private int code;
    private String description;
    // 构造函数，枚举类型只能为私有

    CostType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public CostType setCode(int code) {
        this.code = code;
        return this;
    }

    public String getDescription() {
        return description;
    }

    public CostType setDescription(String description) {
        this.description = description;
        return this;
    }

    @Override
    public String toString() {
        return "CostType{" +
                "code=" + code +
                ", type='" + description + '\'' +
                '}';
    }

    public static CostType getByCode(int type) {
        CostType cartype[] = CostType.values();
        for (int i = 0; i < cartype.length; i++) {
            CostType pw = cartype[i];
            if (pw.getCode() == type) {
                return pw;
            }
        }
        return CostType.Else;
    }
}

